home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ultra Pack
/
UltraComputing Partner Applications.iso
/
Softquad
/
hm2.solaris.tar
/
hm2
/
bin
/
mkfontsrc
< prev
Wrap
Text File
|
1996-01-18
|
3KB
|
152 lines
#! /bin/sh
#
# Shell script to build an A/E 2.1 fontsrc file.
#
# You must be running the X Window system (or OpenWindows or DECWindows, etc)
# in order for this to works, as i has to contact your X display server.
#
# Copyright SoftQuad Inc., 1992
#
# (@)# @(#)mkfontsrc 1.1 92/06/08
#
# X font names are in this format:
#-fndry-fam-wt-slant-sWidth-adstyle-pxlsz-ptsz-xres-yres-spc-avgwid-rgstry-enc
# run the xfontsel program to get a feel for this...
FONTLIST=${SQDIR-/usr/sqps}/lib/fontlist
case "$1" in
[0-9][0-9]*)
RES=$1
;;
*) echo "Usage: $0 screen-resolution (e.g. 75)" 1>&2
echo $0: output will be in ${DISPLAY-"$DISPLAY"}.fontsrc 1>&2
exit 1
;;
esac
if test ! -f "$FONTLIST"
then
echo "$0: could not open fontlist [\$SQDIR=$SQDIR]" 1>&2
cat "$FONTLIST" > /dev/null # make an error message
exit 1
fi
if test x"$DISPLAY" = x""
then
echo "$0: you must set the DISPLAY variable to your X Windows display" 1>&2
exit 1
else
echo "$0: making fontsrc for X display $DISPLAY..." 1>&2
fi
NAWK=
set `echo $PATH | tr ':' ' '`
for i
do
if test -f "$i/mawk"
then NAWK="$i/mawk"
break
fi
done
if [ x"$NAWK" = x"" ]
then
for i
do
if test -f "$i/nawk"
then NAWK="$i/nawk"
break
elif test -f "$i/gawk"
then NAWK="$i/gawk"
break
fi
done
fi
if [ x"$NAWK" = x"" ]
then
NAWK=awk
fi
xlsfonts | fgrep -f $FONTLIST | grep -v .0-0-. |
sort -t- +1 | # sort on font family, not foundry
$NAWK -F- '
#font format:
#-fndry-fam-wt-slant-sWidth-adstyle-pxlsz-ptsz-xres-yres-spc-avgwid-rgstry-enc
BEGIN {
Sizes[8] = 8
Sizes[10] = 10
Sizes[12] = 12
Sizes[14] = 14
Sizes[18] = 18
Sizes[24] = 24
Res = '"${RES}"' + 0
}
(NF != 15) {
# printf "Ignore (%d fields not 15): %s\n", NF, $0 | "cat 1>&2"
next # malformed font name
}
($(10) != $(11)) {
printf "Aspect ratio unknown: %s\n", $0 | "cat 1>&2"
next
}
{
Size = $9 / 10
if (Sizes[Size] + 0 > 0) {
Face = "p"
} else {
# printf "Size %d unknown in %s\n", Size, $0 | "cat 1>&2"
next
}
if ($(11) > Res * 1.1 || $(11) < Res * 0.9) {
if ($11 == 100 || $10 == 75) next
printf "Resolution %d not %d in %s\n", $(11), Res, $0 | "cat 1>&2"
next # wrong resolution
}
} # default
($5 == "i" || $5 == "o") {
Face = "i"
} # italic or oblique
($4 == "bold" || $4 == "demi" || $4 == "demibold") {
if (Face == "p") Face = "b"
else Face = "bi"
}
{
Family = $3
if ($6 != "" && $6 != "normal") Family = Family " " $6
if (FamiliesSeen[Family] == "") {
FamiliesSeen[Family] = $2
} else if (FamiliesSeen[Family] != $2) {
Family = $2 " " Family
}
printf "FONT : %s : %s : %-02.02d : ", Family, Face, Size
for (i = 1; i <= NF; i = i + 1) { # awk does not have ++, blame dns
printf "%s", $i
if (i < NF) printf "-"
}
printf "\n"
}
' > "$DISPLAY".fontsrc
echo "$0: output is in $DISPLAY.fontsrc:"
/bin/ls -l "$DISPLAY".fontsrc